/**
 * @Author: Hhx06
 * @Email: huangshm@yoozoo.com
 * @Description:data
 * @File:  main
 * @Version: 1.0.0
 * @Date: 2022/06/07 10:22
 */

package main

import (
	"flag"
	"github.com/eyotang/boomer"
	"httpTemplate/cache"
	"httpTemplate/client"
	"httpTemplate/log"
	"httpTemplate/message"
	"math/rand"
	"time"
)

func worker(ctx boomer.Context) {
	var (
		err error
	)
	if err = message.DoReq(ctx); err != nil {
		return
	}

}

func main() {
	flag.Parse()
	log.Init()
	cache.Init()
	taskInit := &boomer.Task{
		Weight: 0,
		Name:   "init",
		Fn: func(ctx boomer.Context) {
			c := client.NewClient()
			ctx.Set("conn", c)
			rand.Seed(time.Now().Unix())
		},
	}
	d := &boomer.Task{
		Name: "redis",
		Fn: func(ctx boomer.Context) {
			for {
				worker(ctx)
				time.Sleep(3 * time.Second)
			}

		},
	}

	tasks := []*boomer.Task{d}
	boomer.SetInitTask(taskInit)
	boomer.Run(tasks...)
	//b := boomer.NewStandaloneBoomer(10, 1)
	//b.SetInitTask(taskInit)
	//b.Run(tasks...)

}
